package com.leetcode.No1780;

import org.junit.Test;

/**
 * @program: Solution
 * @description: 判断一个数字是否可以表示成三的幂的和
 * @author: Wang Zhihua
 * @date: 2022-12-09
 */
public class Solution {
    public boolean checkPowersOfThree(int n) {
        while (n > 0) {
            if (n % 3 == 2) {
                return false;
            }
            n /= 3;
        }
        return true;
    }

    @Test
    public void test() {
        System.out.println(checkPowersOfThree(12));

        System.out.println(checkPowersOfThree(91));

        System.out.println(checkPowersOfThree(21));
    }
}
